import styles from './index.module.less'
import Pagination from '@/components/pagination'
import Table from '@/components/table'
import columns from './column'
import { getWithdrawalList } from '@/api/admin'
import { useEffect } from 'react'
import { useSetState } from 'ahooks'

const Index = () => {
  const [formData, setFormData] = useSetState({
    page: 1,
    pageSize: 30,
    list: null,
    total: 0,
  })
  useEffect(() => {
    getWithdrawalList({ page: formData.page, pageSize: formData.pageSize }).then((res) => {
      if (!res.code) {
        setFormData({ list: res.data?.list || [], total: res.data?.total || 0 })
      }
    })
  }, [formData.page])
  return (
    <div className={styles.home}>
      <Table className={styles.tableMainContent} columns={columns()} dataSource={formData.list} height={100} />
      {formData.total > 30 && (
        <Pagination total={formData.total} onChange={(page) => setFormData({ page })} className="mt-7" />
      )}
    </div>
  )
}

export default Index
